﻿using FluentValidation;

namespace MyCompany.MyProject.WebApi.ModelDto.UserDto;

/// <summary>
/// 用户参数验证
/// </summary>
public class UserValidator : AbstractValidator<UserVo>
{
    /// <summary>
    /// 构造函数
    /// </summary>
    public UserValidator()
    {
        RuleFor(x => x.LoginName).NotEmpty().WithMessage("登录名不能为空").MaximumLength(50).WithMessage("登录名长度不能超过50");
        RuleFor(x => x.RealName).NotEmpty().WithMessage("真实姓名不能为空").MaximumLength(50).WithMessage("真实姓名长度不能超过50");
        RuleFor(x => x.LoginPWD).NotEmpty().WithMessage("登录密码不能为空").MaximumLength(50).WithMessage("登录密码长度不能超过50");
        //RuleFor(x => x.Status).NotNull().WithMessage("用户状态不能为空").InclusiveBetween(0, 1).WithMessage("用户状态只能为0或1");
    }
}
